/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package config;

import java.util.Map;

/**
 *
 * @author KieuAnh
 */
abstract class JSONMapArray<E extends JSONable> extends JSONMap<Integer, E>
{
    @Override
    protected Integer keyFromString(String o)
    {
        return Integer.parseInt(o);
    }
    
    public static interface Factory<E extends JSONable>
    {
        E newElem(Map<String, Object> j);
    }
    
    public static <E extends JSONable> JSONMapArray<E>
        fromFactory(final Factory<E> f)
        {
            return new JSONMapArray<E>() {
                @Override
                protected E newElement(Map<String, Object> elemJSON) {
                    return f.newElem(elemJSON);
                }
            };
        }
}
